﻿using FB.Providers.EmployeeInfo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace FB.Providers
{
    public static class TeamManager
    {
        //public static EmployeeInfoUnit EmployeeInfoUnit
        //{
        //    get
        //    {
        //        var EF = AspNetEmployeeInfoProviderManager.Default as EFEmployeeInfoProvider;
        //        if (null != EF)
        //        {
        //            return EF.GetEmployeeInfoUnit();
        //        }
        //        return null;
        //    }
        //}
        //public static Team GetTeam(string TEAMCode)
        //{
        //    EmployeeInfoUnit infounit = EmployeeInfoUnit;
        //    var query = infounit.TeamRepository.Get(t => t.TEAMCode == TEAMCode, null, "Department");
        //    return query.FirstOrDefault(); 
        //}

        //public static List<Team> GetAllTeams()
        //{
        //    EmployeeInfoUnit infounit = EmployeeInfoUnit;
        //    return infounit.TeamRepository.Get().ToList(); 
        //}

        //public static List<Team> FindTeams(Expression<Func<Team, bool>> filter = null)
        //{
        //    EmployeeInfoUnit infounit = EmployeeInfoUnit;
        //    return infounit.TeamRepository.Get(filter, null, "Department").ToList(); 
        //}

        //public static Team CreateTeam(Team team)
        //{
         
        //    EmployeeInfoUnit infounit = EmployeeInfoUnit;
        //    Team t = infounit.TeamRepository.Insert(team);
        //    infounit.SaveChanges();
        //    return t;
        //}

        //public static void UpdateTeam(Team team)
        //{
        //    EmployeeInfoUnit infounit = EmployeeInfoUnit;
        //    infounit.TeamRepository.Update(team);
        //    infounit.SaveChanges();
            
        //}

        //public static void DeleteTeam(string TEAMCode)
        //{
        //    EmployeeInfoUnit infounit = EmployeeInfoUnit;
        //    infounit.TeamRepository.Delete(TEAMCode);
        //    infounit.SaveChanges();
        //}
        //public static List<Team> QueryTeams(
        // IList<Expression<Func<Team, bool>>> filters,
        // Func<IQueryable<Team>, IOrderedQueryable<Team>> orderBy,
        // int pageIndex, int pageSize, out int totalRecords)
        //{
        //    EmployeeInfoUnit infounit = EmployeeInfoUnit;
        //    var query = infounit.TeamRepository.Get(null, orderBy, "Department");
        //    if (filters != null)
        //    {
        //        foreach (Expression<Func<Team, bool>> item in filters)
        //        {
        //            query=query.Where(item);
        //        }
        //    }
        //    totalRecords = query.Count();
        //    return query.Skip(pageIndex * pageSize).Take(pageSize).ToList();
            
        //}
        //public static List<Team> FindTeams(
        // Expression<Func<Team, bool>> filter,
        // Func<IQueryable<Team>, IOrderedQueryable<Team>> orderBy,
        // int pageIndex, int pageSize, out int totalRecords)
        //{
        //    EmployeeInfoUnit infounit = EmployeeInfoUnit;
        //    return infounit.TeamRepository.GetPagedList(filter, orderBy, pageIndex, pageSize, out totalRecords, "Department").ToList();
            
        //}
    }
}
